home *** CD-ROM | disk | FTP | other *** search
/ Fritz: All Fritz / All Fritz.zip / All Fritz / FILES / SPREOTUS / 123TECH.LZH / DATAFILL.TXT < prev    next >
Text File  |  1984-11-24  |  8KB  |  196 lines

  1.            TIPS ON USING 1-2-3
  2.  
  3.            This time, our "Tips" column features the versatile /Data Fill
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.            command and other helpful 1-2-3 pointers.  The /Data Fill command
  21.            lives a double life.  As a regular 1-2-3 command, it comes in
  22.            handy for putting sequences of numbers in ranges.  In macros, it
  23.            becomes a powerful tool for putting numbers in cells anywhere in
  24.            the worksheet, for performing calculations, and even for
  25.            controlling loops.
  26.  
  27.  
  28.            Reviewing the Command
  29.  
  30.            When you select /Data Fill, 1-2-3 asks you first to indicate a
  31.            range to be filled, then for three values: the number with which
  32.            to Start the sequence, the number to add to that number in each
  33.            Step, and the value at which to Stop filling the range.
  34.  
  35.            Two facts about this command make it very useful in macros.  (1) When it
  36.           asks for numbers, you can type formulas (including cell references),
  37.           functions or range names.  When 1-2-3 fills the range, it evaluates the
  38.           formulas and puts numbers, not formulas, in the cells in the range.  (2) If
  39.           the fill range is just a single cell, it simply puts the value of the Start
  40.           formula in that cell, and ignores the matter of Step and Stop values.
  41.  
  42.            In a macro to put the value of "FORMULA" in the cell named CELL,
  43.            just type:
  44.  
  45.                    /dfCELL~FORMULA~~~
  46.  
  47.            Note the tildes -- one after the name of the range (CELL) to get
  48.            the value, one after the formula, and two more for Start and Step.
  49.  
  50.  
  51.            The Datestamp Macro (\D)
  52.  
  53.            The last "Tips" column suggested setting up standard worksheet
  54.            templates for letters and memos, including a cell with @TODAY
  55.            formatted to show the date.  If you then tell the computer the
  56.            current date when you start it up, printed copies of these
  57.            template-produced documents will always indicate the date of
  58.            printing.
  59.  
  60.            But what happens if you save the newly written memo under a
  61.            different name from that of the template?  No matter when you
  62.            retrieve it, you see the date of the memo's creation.  However,
  63.            the Datestamp macro offers the ability to automatically print the
  64.            present date.  You still use a cell formatted to show Dates, only
  65.            this time you put in the value @TODAY, not the formula.  Name the
  66.            cell DATE.  Here's the macro:
  67.  
  68.                 \D     /dfDATE~@TODAY~~~     Put the value of @TODAY in the cell
  69.                                              named DATE.
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.            Counting Loops
  88.  
  89.            In the last column, we wrote a macro that "looped" until it found
  90.            a particular value in a cell.  Sometimes, however, you want to
  91.            stop a macro from repeating after it has looped a particular
  92.            number of times.  To enable 1-2-3 to count the number of loops,
  93.            put the value for the maximum number of loops in a cell named
  94.            LIMIT, and keep the count in a cell named COUNT.  Every time the
  95.            macro repeats, you want 1-2-3 to add one to COUNT, i.e. increment
  96.            the count.  Next, put an /xi (if) command in the macro to stop it
  97.            when COUNT > LIMIT.
  98.  
  99.            Because range names can be used in formulas, /Data Fill can be
  100.            useful in this counting macro.  To increment COUNT, just type:
  101.  
  102.                      /dfCOUNT~COUNT+1~~~       Compute the value of COUNT+1 and
  103.                                                place it in the cell named COUNT.
  104.  
  105.            Here are the macro instructions that control the loop:
  106.  
  107.                     /dfCOUNT~1~~~                      Start the counter at one.
  108.            LOOP     [whatever macro instructions       Cell named LOOP.
  109.                     are to be repeated]
  110.                     /dfCOUNT~COUNT+1~~~                Add one to the counter.
  111.                     /xi(COUNT>LIMIT)~/xq               Stop when COUNT exceeds LIMIT.
  112.                     /xgLOOP~                           Otherwise, repeat the LOOP.
  113.  
  114.            This is only one of many versions of a loop with a counter.  You
  115.            could, for example, ask the user for the value to put in LIMIT
  116.            (use the /xn command), or have loops within loops.  The /Data Fill
  117.            command boosts the programming power of 1-2-3's macros.
  118.  
  119.  
  120.            Non-Macro tips with [End]
  121.  
  122.            As you have probably learned, the [End] key is a great help in
  123.            getting around the worksheet.  If you are at the top of a column
  124.            of numbers, typing [End] [Down] takes you to the bottom of the
  125.            column.  If you are in an empty cell, [End] followed by a
  126.            cursor-motion key takes you to the first non-empty cell in that
  127.            direction.  Here are two more uses of [End] that you may not have
  128.            discovered: copying formulas in adjacent columns and finding the
  129.            bottom of a range.
  130.  
  131.            In working with spreadsheets, it is common to have a formula that
  132.            you want to copy adjacent to every cell in a column, or under
  133.            every cell in a row.  To do so you put the cell pointer on the
  134.            formula, select /Copy, and then press [Return] to indicate the
  135.            formula to be copied.  Then you point out the range to which to
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.            copy the formula.  The problem is that there's usually nothing in
  153.            that range yet, so you can't use [End].  Or can you?
  154.  
  155.            To use [End] to copy formulas adjacent to a column, anchor the top
  156.            of the new column of formulas with [.].  Then, using the
  157.            cursor-motion keys, put the free end of the range in the column
  158.            that already has values.  Press [End] [Down] to tack down the free
  159.            end of that column, and use a cursor-motion key, usually [Right]),
  160.            to bring the free end into the column you want to copy to.  Since
  161.            that's the right range, press [Return] and you're done.
  162.  
  163.            Sounds complicated?  Actually it's harder to read about than to
  164.            do.  Here's an example.  You have numbers in columns A and B, for
  165.            a large number of rows.  You want to put a formula in every cell
  166.            of column C, next to those numbers.  Give it a try.
  167.  
  168.            1) Go to the first row in column C and type the formula, say
  169.            +A1+B1.  2) Select /Copy.  3) Press [Return] [.].  4) Press [Left]
  170.            [End] [Down] [Right] [Return].
  171.  
  172.            You can also use [End] to find the bottom of a range.  Because the
  173.            presence of blank cells can slow the process if you start from the
  174.            top of the block of data, it's best to approach using [End] from
  175.            the bottom up.  Like the above tip, this is easier to do than to
  176.            read about.  Just try it.  To find the bottom of a column with
  177.            blank cells in it simply
  178.  
  179.            Page down past the end and press [End] [Up].
  180.  
  181.            Or, if a nearby column is empty,
  182.  
  183.            1) Go to the end of the empty column.  2) Press [End] [Down] to
  184.            get to the bottom of the worksheet.  3) Move back to the column
  185.            whose end you want to locate.  4) Press [End] [Up].
  186.  
  187.            In Summary
  188.  
  189.            The [End] key techniques are very handy in day-to-day work with
  190.            1-2-3.  What's more, you can use the very same tricks with
  191.            Symphony.  The /Data Fill command is a great tool for macro
  192.            writers.  By the way, when the 1-2-3 Manual was written, we hadn't
  193.            discovered all the ways /Data Fill could be used.  It all points
  194.            out one of the things I like about 1-2-3 -- it is always new ...
  195.            there are still discoveries to be made.
  196.